﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Hive.Core.Model.Schema
{
    /// <summary>
    /// An Xml serializable representation of a descriptor child.
    /// </summary>
    [Serializable]
    [XmlType(Namespace = SchemaConstants.XmlNamespace)]
    public sealed class DescriptorChild : DescriptorRoot
    {
        /// <summary>
        /// Creates an uninitialized descriptor child.
        /// </summary>
        public DescriptorChild()
        {
        }

        /// <summary>
        /// Creates a descriptor child initialized from the specified key and descriptor.
        /// </summary>
        /// <param name="key">The child key.</param>
        /// <param name="descriptor">The child descriptor.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="key"/> or 
        /// <paramref name="descriptor"/> is null.</exception>
        public DescriptorChild(string key, Descriptor descriptor)
            : base(descriptor)
        {
            if (key == null)
                throw new ArgumentNullException("key");

            Key = key;
        }

        /// <summary>
        /// Gets or sets the child key.
        /// </summary>
        [XmlAttribute("key")]
        public string Key { get; set; }
    }
}
